import React from 'react';

import { Card,Button } from 'antd';

import { isEmpty} from './common';

import UIIcon from './uicomponents/UIIcon';

import PageContent from './PageContent';

export default class DefaultDomainPahe extends React.Component{

    openPage = (menuItem) => {
        //console.log(menuItem);
        const {pageRouter} = this.props;
        if(isEmpty(menuItem.path)){
            pageRouter.goto('/openDomianDefaultPage' ,{
                icon : menuItem.icon,
                shortName : menuItem.label,
                menuItems : menuItem.subItems,
            });
        }
        else{
            pageRouter.goto('/' + menuItem.path,menuItem);
        }
    }

    render(){

        const domain = this.props.location.state;

        const menuItems = domain.menuItems

        const gridStyle = {
            width: '25%',
            textAlign: 'center',
          };

        //console.log(domain);

        return(
         <PageContent {...this.props} currentModule={{label : domain.shortName,icon : domain.icon,remarks:domain.remarks}}>
            <Card>
            {
                menuItems.map(menuItem => {
                    return (
                        <Card.Grid key={menuItem.menuId} style={gridStyle}><Button type="link" block onClick={(evnt) => {this.openPage(menuItem)}}> <span style={{color:'black'}}> <UIIcon icon={menuItem.icon} />{menuItem.label}</span> </Button> </Card.Grid>
                    );
                })
            }
            </Card>
        </PageContent>
        );
    }
}
